package scantask.tests;

import java.util.Set;
import java.util.Vector;

import junit.framework.TestCase;
import scantask.containers.Benchmark;
import scantask.containers.Coordinate;
import scantask.containers.InformationObject;
import scantask.containers.exceptions.InvalidCoordinateValueException;
import scantask.containers.exceptions.InvalidWeekNumberException;
import scantask.containers.exceptions.InvalidYearException;
import scantask.containers.exceptions.UnInitializeObjectException;
import scantask.server.domainLayer.Controller;
import scantask.server.domainLayer.Exceptions.ControllerException;
import scantask.server.domainLayer.Exceptions.LoginException;

public class AcceptanceTest extends TestCase {

	private scantask.server.domainLayer.Controller _serverControl;
	private scantask.client.domainLayer.Controller _clientControl;
	public AcceptanceTest(){
		this._serverControl = new Controller();
		this._clientControl = new scantask.client.domainLayer.Controller();
	}
	
	public boolean login(String userName, String password){
		try {
			this._clientControl.login(userName, password);
			return true;
		} catch (ControllerException e) {
			return false;
		}
	}
	
	public boolean logout(String user){
		try {
			this._clientControl.logout();
			return true;
		} catch (LoginException e) {
			return false;
		}
	}
	
	public Vector<InformationObject> viewHistory(int year,int  week){
		try {
			return this._clientControl.viewHistory(year, week);
			
		} catch (LoginException e) {
			return null;
		} catch (InvalidWeekNumberException e) {
			return null;
		} catch (InvalidYearException e) {
			return null;
		} catch (ControllerException e) {
			return null;
		}
	}
	public Vector<Benchmark> getBenchmarks(){
		try {
			return this._clientControl.getBenchmarks();
		} catch (LoginException e) {
			return null;
		}
	}
	public Set<String> getDataTypes(){
		try {
			return this._clientControl.getDataTypes();
		} catch (LoginException e) {
			return null;
		}
	}
	
	public Coordinate getDefaultCoordinate(){
		try {
			return this._clientControl.getDefaultCoordinate();
		} catch (LoginException e) {
			return null;
		} catch (UnInitializeObjectException e) {
		return null;
		}
	}
	public boolean addBenchmark(String locationName, int x, int y){
		try {
			
			this._clientControl.addBenchmark(locationName, x, y);
			return true;
		} catch (InvalidCoordinateValueException e) {
			return false;
		} catch (ControllerException e) {
			return false;
		}
	}
	

}
